1. Technical Field
The present invention relates to a method and apparatus for data processing in general, and in particular to a method and apparatus for processing floating-point numbers. Still more particularly, the present invention relates to a method and apparatus for generating shift amount signals for an alignment shifter.
2. Description of the Prior Art
According to the IEEE standard, a floating-point number consists of a mantissa (M), an exponent (E), and a sign (S). For example, a floating-point number 1234.56 can be specified by 1.0011010010xc3x97210, where M=1.0011010010, E=10, and S=0. When performing floating-point arithmetic, the exponents of two floating-point numbers are required to be aligned before any addition or subtraction of the mantissas of the two floating-point numbers can be performed. For example, the addition of floating-point numbers 1234.56 (M=1.0011010010 and E=10) and 123.456 (M=1.111011 and E=6) requires an alignment of the mantissas by the amount of the difference of their exponents, that is, 10xe2x88x926=4.
Generally speaking, the mantissa of a floating-point number having a smaller exponent is required to be shifted to the right by an amount equal to the difference in exponents. This allows the usage of an unidirectional alignment shifter that is easier and less complicated than a bidirectional alignment shifter. Otherwise, in some cases in which one of the mantissas is not readily available by reason of the arithmetic operations, the available mantissa is always shifted to align with the unavailable mantissa using the exponents to determine the proper shift amount. This requires an alignment shifter that is capable of shifting in both directions depending on which of the two exponents is greater. The present disclosure provides an improved method for generating shift amount signals to drive an alignment shifter.
In a process of adding a first floating-point number and a second floating-point number, wherein the floating-point numbers includes a sign, a mantissa, and an exponent, an alignment shifter is used to provide proper alignment for the floating-point numbers. In accordance with a preferred embodiment of the present invention, residue arithmetic is performed on an exponent of the first floating-point number and an exponent of the second floating-point number to generate a residue shift amount. The residue shift amount is then decoded to obtain shift amount signals that are used by the alignment shifter.
All objects, features, and advantages of the present invention will become apparent in the following detailed written description.